package com.spdd.mt.app.api;

import com.spdd.mt.app.aop.sign.ValidateSign;
import com.spdd.mt.biz.manager.feign.request.ProductMaintenanceRequest;
import com.spdd.mt.biz.manager.model.WebResponse;
import com.spdd.mt.biz.manager.service.ProductService;
import com.spdd.mt.common.util.JacksonUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 微服务内部调用的服务
 */
@Slf4j
@RestController
@RequestMapping("/feign")
public class FeignController {

    @Autowired
    private ProductService productService;

    /**
     * 商品维护信息处理接口
     *
     * @param maintenanceRequest 维护请求参数
     */
    @PostMapping(value = "/product/maintenance")
    public WebResponse productMaintenance(@RequestBody @Validated ProductMaintenanceRequest maintenanceRequest) {
        log.info("商品维护信息处理接口，请求参数:{}", JacksonUtils.toJson(maintenanceRequest));

        WebResponse response = productService.productMaintenanceUpdate(maintenanceRequest);

        log.info("商品维护信息处理接口响应为:{}", JacksonUtils.toJson(response));

        return response;
    }

}
